import request from '@/router/axios'

/*
* 新增产品
* */
export function postProduct(obj) {
    return request({
        url: '/cp/product',
        method: 'post',
        data: obj
    })
}

/*
* 分页查询产品
* */
export function getProduct(query) {
    return request({
        url: '/cp/product/page',
        method: 'get',
        params: query
    })
}

/*
* 编辑产品
* */
export function putProduct(obj) {
    return request({
        url: '/cp/product',
        method: 'put',
        data: obj
    })
}

/*
* 根据id删除产品
* */
export function deleteProduct(productId) {
    return request({
        url: `/cp/product/${productId}`,
        method: 'delete'
    })
}

/*
* 上架产品
* */
export function postPublish(productId) {
    return request({
        url: `/cp/product/publish/${productId}`,
        method: 'post'
    })

}

/*
*

下架产品
* */
export function postPublishOff(productId) {
    return request({
        url: `/cp/product/publish-off/${productId}`,
        method: 'post'
    })
}

/*
* 开启精选/关闭精选
* */
export function postProductSelection(productId) {
    return request({
        url: `/cp/product/select/${productId}`,
        method: 'post'
    })
}
